package com.zp.self.module.level_5_设计模式.行为型模式.Ⅶ_中介者模式;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author ：by Zeng Peng
 * @date ：Created 2022/7/4 21:30
 * @description ：
 */
public class ServiceMediator implements Mediator{
    private Map<String,AbstractTarget> targets = new HashMap<>();

    @Override
    public void registerUser(AbstractTarget target, String name) {
        targets.put(name,target);
    }

    @Override
    public void forwardMessage(List<String> userNames, String msg) {
        for (String userName : userNames) {
            targets.get(userName).receive(msg);
        }
    }
}
